package excelanttasks;

import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Task;

/**
 * Ant Task for transforming Excel sheets to Flex property files.
 * 
 * @author Norbert Kopcsek
 */
public class ConvertExcel extends Task {
	
	private Integer headerRowNumber = 2;
	private Integer keyColumnNumber = 1;
	private String excelPath;
	private String localePath;
	private String resourceName;
	
	@Override
	public void execute()
		throws BuildException {
		
		System.out.println("Excel path is " + excelPath + ".");
		System.out.println("Locale path is " + localePath + ".");
		System.out.println("Resource name is " + resourceName + ".");
		System.out.println("Header row number is " + headerRowNumber + ".");
		System.out.println("Key column number is " + keyColumnNumber + ".");

		ExcelToLocalesConverter converter = new ExcelToLocalesConverter();
		if(excelPath!=null) converter.excelPath = excelPath;
		if(localePath!=null) converter.localePath = localePath;
		if(resourceName!=null) converter.resourceName = resourceName;
		if(headerRowNumber!=null) converter.headerRowNumber = headerRowNumber;
		if(keyColumnNumber!=null) converter.keyColumnNumber = keyColumnNumber;
		
		converter.convert();
	    System.out.println("Done");
	}
	
	public static void main(String[] args) {
		ExcelToLocalesConverter converter = new ExcelToLocalesConverter();
		converter.convert();
	}
	
	public void setExcelPath(String excelPath) {
		this.excelPath = excelPath;
	}
	public void setLocalePath(String localePath) {
		this.localePath = localePath;
	}
	public void setResourceName(String resourceName) {
		this.resourceName = resourceName;
	}
	public void setHeaderRowNumber(Integer headerRowNumber) {
		this.headerRowNumber = headerRowNumber;
	}
	public void setKeyColumnNumber(Integer keyColumnNumber) {
		this.keyColumnNumber = keyColumnNumber;
	}
}